﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace GestureDemo.Transition
{
    public abstract class PageTransition : DependencyObject
    {
        public virtual double AnimationDuration
        {
            get
            {
                return 1000.0;
            }
        }

        public double FractionalBaseIndex
        {
            get { return (double)GetValue(FractionalBaseIndexProperty); }
            set { SetValue(FractionalBaseIndexProperty, value); }
        }

        public static readonly DependencyProperty FractionalBaseIndexProperty =
            DependencyProperty.Register("FractionalBaseIndex", typeof(double), typeof(PageTransition), new PropertyMetadata(-1.0, OnBaseIndexChanged));


        private static void OnBaseIndexChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            PageTransition pageTransition = (PageTransition)d;
            pageTransition.InitInfo(e);
        }

        private void InitInfo(DependencyPropertyChangedEventArgs e)
        {
            double num = (3 + FractionalBaseIndex) % 1;
            int baseIndex = (int)(3.0 + this.FractionalBaseIndex - num) % 3;
            ShowPageTransition(baseIndex,num);
        }

        protected abstract void ShowPageTransition(int baseIndex,double flickNum);
        public abstract void Attach(Panel containerPanel, FrameworkElement pageContainer0, FrameworkElement pageContainer1, FrameworkElement pageContainer2);
        public abstract void Detach();
    }
}
